/* Exercise 5.31
   ejer5_31.c */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int flip( void );

/* function main begins program execution */
int main( void )
{
    int i;
    int tails, heads;

    srand( time( NULL ));

    tails = 0;
    heads = 0;

    for ( i = 1; i <= 100; i++ )
    {
        if ( flip() == 1 )
            ++heads;
        else
            ++tails;
    }

    printf( "Tails: %d\nHeads: %d\n", tails, heads);
	return 0; /* indicate that program ended successfully */
} /* end function main */

int flip( void )
{
    return rand() % 2;
}
